local oo = require("SharedLibs.BaseLib")
AsyncOpState = require("SharedLibs.AsyncOpState");
AsyncOp = require("SharedLibs.AsyncOp");

SyncOp = oo.Class()
SyncOp.name = "SyncOp"
oo.ClassExtends(SyncOp, AsyncOp)

function SyncOp.prototype.constructor(self, retValue)
	SyncOp._ss.prototype.constructor(self)
	
	self._state = AsyncOpState.Ready
	self._returnValue = retValue
end

--- 因为使用了静态对象_Default, 这意味着不能在两个线程(真正的OS Thread)同时使用SyncOp!
function SyncOp.Default(self, value)
	SyncOp._Default._returnValue = value;
	SyncOp._Default._state = AsyncOpState.Ready;
	return SyncOp._Default
end

function SyncOp.prototype:GetReturn()
	return self._returnValue
end

function SyncOp.prototype:_onStart()
	self:_doStop(true);
end

SyncOp._Default = oo.New(SyncOp, nil)

return SyncOp;
